// TypeScript file
class BloodBar extends egret.Sprite
{
    private r: egret.Rectangle;
    private w: number = 0;
    private barBitmap: egret.Bitmap;
    constructor()
    {
        super();
        this.initView();
    }

    private initView(): void
    {
        let barBg: egret.Bitmap = ResourceUtils.createBitmapByName("blodBarBg_png");
        this.addChild(barBg);
        let bloodBar: egret.Bitmap = ResourceUtils.createBitmapByName("blodBar_png");
        this.addChild(bloodBar);
        bloodBar.x = 38;
        bloodBar.y = 8;
        this.w = bloodBar.width;
        this.r = new egret.Rectangle();
       
        this.r.x = 0;
        this.r.y = 0;
        this.r.width = bloodBar.width;
        this.r.height = bloodBar.height;
        bloodBar.mask = this.r;
        this.barBitmap = bloodBar;
    }
    public scaleBlodX(): void
    {
        this.r.x = -(this.w - this.w * (GameData.blood / GameData.maxBlood));
        this.barBitmap.mask = this.r;
    }
}   